Add SQL style linter (vendored Postgres-Extensions/linter) - #16
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Rebuilt fresh on top of current master, containing only the actual CI/pgxn-tools migration (the SQL style linter integration and the cat_tools 0.3.0 dependency fix that had scope-crept into this branch are split out to #16 and #28 respectively). - Add .github/workflows/ci.yml: a `changes` job (docs-only gate + PG-major-matrix derivation from two constants), a `test` matrix job (container: pgxn/pgxn-tools, PostgreSQL 12-18), and an `all-checks-passed` aggregation gate for use as a single stable required status check. - Remove .travis.yml and pg-travis-test.sh, superseded by the above. - test/dump/run.sh: add -X to several psql invocations, disabling ~/.psqlrc so test runs are deterministic.
Reconciles the substantive feature delta from new_features (PR #2) onto the current 'stable' baseline (post PR #5/#16: pgxn-tools testing, cat_tools 0.3.0, and the linter): - _object_reference._object_oid: drop the per-catalog regclass/regconfig/ regdictionary/regnamespace/regoperator/regprocedure/regtype columns and their unique indexes plus the count_nulls-backed null_count trigger that enforced "exactly one is set". classid is now plain oid and object_oid (also NOT NULL) is the sole identifier column, so there's nothing left to arbitrate between. - _object_reference._object_v / _object_v__for_update: drop the reg* columns from the column list to match. - _object_reference._object_oid__add: replace the dynamic, format()-built INSERT that picked a reg* column based on cat_tools.object__reg_type() with a plain INSERT into object_oid. - Drop the count_nulls search_path DO block (dead now that the trigger using it is gone) and the count_nulls dependency throughout (control, Makefile, test setup). - Add object_reference.object__describe()/object__identity(), thin wrappers around pg_describe_object()/pg_identify_object(); and object__cleanup(), which best-effort deletes an object record (ignoring foreign_key_violation if it's still referenced elsewhere). Wire object__cleanup() up to a new AFTER DELETE trigger on object_group__object so removing an object from its last group automatically attempts cleanup. - _object_v__for_update (the getsert core): refuse to track objects living in a pg_temp*/pg_toast_temp* schema, since a tracked reference would outlive the temporary object it points to. - test/sql/object_group.sql: switch the two scratch tables from TEMP to regular tables (object__getsert now rejects temp objects) and add coverage for the new automatic-cleanup trigger. - test/sql/base.sql: replace the count_nulls-relocation test (relocation was already unsupported and the whole extension no longer depends on count_nulls) with coverage for object_oid, object__describe(), object__identity(), and temp-object rejection. sql/object_reference--0.1.0.sql (the frozen historical release) and the META files are untouched. default_version stays 'stable'; sql/object_reference--stable.sql is regenerated to match sql/object_reference.sql. make lint and make test (including the dump/restore test) pass on both PostgreSQL 12 and 17. Supersedes PR #2 (new_features) and, for the update/upgrade test infrastructure built on top of it, sets up the rebuild of PR #3. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0.1.0 and stable are byte-identical for this function's body once the linter's annotation (PR #16's own, separate content) isn't part of this branch -- the CREATE OR REPLACE was a no-op here. Verified via bin/test_existing's structural diff (clean) and a full local run (7/7 pgTAP files, dump/restore, test-build).
Reconciles the substantive feature delta from new_features (PR #2) onto the current 'stable' baseline (post PR #5/#16: pgxn-tools testing, cat_tools 0.3.0, and the linter): - _object_reference._object_oid: drop the per-catalog regclass/regconfig/ regdictionary/regnamespace/regoperator/regprocedure/regtype columns and their unique indexes plus the count_nulls-backed null_count trigger that enforced "exactly one is set". classid is now plain oid and object_oid (also NOT NULL) is the sole identifier column, so there's nothing left to arbitrate between. - _object_reference._object_v / _object_v__for_update: drop the reg* columns from the column list to match. - _object_reference._object_oid__add: replace the dynamic, format()-built INSERT that picked a reg* column based on cat_tools.object__reg_type() with a plain INSERT into object_oid. - Drop the count_nulls search_path DO block (dead now that the trigger using it is gone) and the count_nulls dependency throughout (control, Makefile, test setup). - Add object_reference.object__describe()/object__identity(), thin wrappers around pg_describe_object()/pg_identify_object(); and object__cleanup(), which best-effort deletes an object record (ignoring foreign_key_violation if it's still referenced elsewhere). Wire object__cleanup() up to a new AFTER DELETE trigger on object_group__object so removing an object from its last group automatically attempts cleanup. - _object_v__for_update (the getsert core): refuse to track objects living in a pg_temp*/pg_toast_temp* schema, since a tracked reference would outlive the temporary object it points to. - test/sql/object_group.sql: switch the two scratch tables from TEMP to regular tables (object__getsert now rejects temp objects) and add coverage for the new automatic-cleanup trigger. - test/sql/base.sql: replace the count_nulls-relocation test (relocation was already unsupported and the whole extension no longer depends on count_nulls) with coverage for object_oid, object__describe(), object__identity(), and temp-object rejection. sql/object_reference--0.1.0.sql (the frozen historical release) and the META files are untouched. default_version stays 'stable'; sql/object_reference--stable.sql is regenerated to match sql/object_reference.sql. make lint and make test (including the dump/restore test) pass on both PostgreSQL 12 and 17. Supersedes PR #2 (new_features) and, for the update/upgrade test infrastructure built on top of it, sets up the rebuild of PR #3. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0.1.0 and stable are byte-identical for this function's body once the linter's annotation (PR #16's own, separate content) isn't part of this branch -- the CREATE OR REPLACE was a no-op here. Verified via bin/test_existing's structural diff (clean) and a full local run (7/7 pgTAP files, dump/restore, test-build).
60eb192 to
159f6c9
Compare
|
Claude finished @jnasbyupgrade's task in 2m 33s —— View job Claude finished the reviewTodo list
SummaryThis is a clean, well-scoped PR. I read through the full diff ( CI wiring (
Makefile /
SQL changes
No bugs, correctness issues, or security concerns found. Nice attention to detail in the PR description explaining why each mechanical choice (the |
Vendor Postgres-Extensions/linter as a git submodule at .vendor/linter,
following the same pattern already adopted in cat_tools: a thin
self-initializing lint.mk hand-off (so `make lint` works right after a
plain `git clone`, no --recurse-submodules needed), LINT_TARGETS scoped
to sql/object_reference.sql and test/ (excluding the frozen, never
hand-edited versioned install files under sql/, e.g.
object_reference--0.1.0.sql/--stable.sql), and a CI job that runs
`make lint` directly -- the same entry point a developer uses locally
-- so the self-init logic is actually exercised, not just the rule
checking.
The `include lint.mk` is guarded on .git being present: a tarball build
(PGXN distribution, `git archive` with no .git) has no submodule to
initialize, and Make resolves every `include` before running any
target regardless of which one was requested, so an unguarded rule
would break `make`/`make install` entirely for a tarball build, not
just `make lint`.
Fixes the real pre-existing style findings this first run turned up
(52 total): most were commented-out SQL marked as prose comments
instead of using the linter's `EXCLUDED CODE` disabled-code convention
(missing " * " prefixes flagged as comment-line-prefix/comment-opening
violations); one COPY data block's `secondary` column intentionally
mirrors pg_catalog's own type display name ("integer" for int4) rather
than following prefer-short-type, so it's suppressed via a scoped
disable-block region instead of being "fixed" into incorrect test data.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- sql/object_reference.sql: the commented-out CREATE TEMP TABLE ... AS alternative in the ddl_capture exception handler was dead weight, not a real alternative worth preserving in a comment. - test/helpers/object_table.sql: the disable-block was working around the linter scanning raw COPY payload text for type-name substrings. A quoted string literal isn't scanned at all, so a plain multi-row INSERT needs no suppression -- same data, properly quoted.
159f6c9 to
7e03424
Compare
|
Claude finished @jnasbyupgrade's task in 1m 37s —— View job Claude finished the reviewTodo list
SummaryReviewed the full diff ( CI wiring (
Makefile /
SQL changes
No bugs, correctness issues, or security concerns found. This PR is well-scoped, and the description clearly explains the reasoning behind each mechanical choice (the |
…instead
Reverts the earlier INSERT-VALUES rewrite. Wraps the original COPY ...
FROM STDIN payload in a sql-lint:disable-block prefer-short-type /
enable-block region instead -- the raw text triggers 2 real findings
("integer"/"int4" inside data, not type references) that the rewrite
worked around by restructuring the data instead of just telling the
linter to ignore this specific, known-safe case.
Co-Authored-By: Claude <noreply@anthropic.com>
|
Claude finished @jnasbyupgrade's task in 1m 37s —— View job Claude finished reviewingTodo list
SummaryThis push (
No bugs, correctness issues, or security concerns found. LGTM. |
Vendors
Postgres-Extensions/linteras a git submodule at.vendor/linter, with a thin self-initializinglint.mkhand-off somake lintworks right after a plaingit clone(no--recurse-submodulesneeded), and wires it into CI as alintjob gated the same way the PG-version test matrix already is (skipped on docs-only pushes).LINT_TARGETSis scoped tosql/object_reference.sqlandtest/, excluding the versioned install/update files undersql/(object_reference--0.1.0.sql,object_reference--stable.sql) — those are frozen/generated per this repo's own convention, so linting them would produce permanent, unfixable findings.include lint.mkis guarded behindifneq ($(wildcard .git),): a tarball build (PGXN distribution, or anygit archivecheckout with no.git) has no submodule to initialize, and Make resolves everyincludebefore running any target regardless of which one was requested, so an unguarded rule would breakmake/make installentirely for a tarball build, not justmake lint. Verified with a realgit archive HEAD | tar -xcheckout:makeandmake installboth succeed with no.gitpresent.lintCI job checks out without submodules so the self-init logic inlint.mkis actually exercised, not papered over with asubmodules: truecheckout.The first
make lintrun againstsql/object_reference.sql/test/found 52 real findings, fixed here rather than suppressed:/*) instead of the linter'sEXCLUDED CODEdisabled-code convention (an alias forsql-lint:disable-block all). Converted each to/* EXCLUDED CODE[: reason], preserving existingTODO:context as the reason where present.test/helpers/object_table.sql'sCOPY ... FROM STDINfixture block is replaced with a plain multi-rowINSERT: the linter scans rawCOPYpayload text for type-name substrings, so itssecondarycolumn valueinteger(pg_catalog's own display name forint4, intentionally preserved as-is in the test data) trippedprefer-short-type. A quoted string literal in anINSERTisn't scanned the same way, so no suppression comment is needed at all.test/sql/event_trigger.sql) was missing a space after*.The dead commented-out
CREATE TEMP TABLE ... ASalternative insql/object_reference.sql'sddl_captureexception handler is dropped rather than reformatted — it wasn't a real alternative worth preserving in a comment.